package com.liyuxiang.yygh.hosp.controller;

import com.liyuxiang.yygh.common.result.Result;
import com.liyuxiang.yygh.hosp.service.HospitalService;
import com.liyuxiang.yygh.model.hosp.Hospital;
import com.liyuxiang.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;

    @GetMapping("/list/{current}/{limit}")
    public Result getHospitalList(@PathVariable("current") Integer current, @PathVariable("limit") Integer limit, HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitalPage = hospitalService.getHospitalPage(current, limit, hospitalQueryVo);
        return Result.ok(hospitalPage);
    }

    @GetMapping("/updateHospStatus/{id}/{status}")
    public Result updateHospStatusById(@PathVariable("id") String id, @PathVariable("status") int status) {
        Boolean flag = hospitalService.updateHospStatusById(id, status);
        return flag ? Result.ok() : Result.fail();
    }
    @GetMapping("/showHospDetail/{id}")
    public Result getHospDetailById(@PathVariable("id")String id){
        Hospital hospital = hospitalService.getHospDetailById(id);
        return Result.ok(hospital);
    }
}
